package day2.dict_service.tcp;

import java.io.*;
import java.net.Socket;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 8080);

        InputStream is = socket.getInputStream();
        Scanner scanner = new Scanner(is, "UTF-8");

        OutputStream os = socket.getOutputStream();
        OutputStreamWriter writer = new OutputStreamWriter(os, "UTF-8");
        PrintWriter printWriter = new PrintWriter(writer);

        // 发送请求
        printWriter.printf("我是Java19班的\r\napple\r\n");
        printWriter.flush();

        // 读取响应
        String header = scanner.nextLine(); // 好的
        String word = scanner.nextLine();   // 苹果
        System.out.println(word);

        socket.close();
    }
}
